﻿using System;
using System.Collections.Generic;
using TheClerk.Access;
using Org.BouncyCastle.Asn1;

namespace TheClerk.Forms
{
    /// <summary>
    /// A field is a singular index/value pair: the index is a string (unique
    /// in the scope of the Form) and the value is a Collection.
    /// </summary>
    /// <remarks>
    /// classic explanation: key/value pair, with key being something which can
    /// be converted to a string, and value is a dictionary.
    /// 
    /// clerk explanation: index/value pair, index is a string, and the value
    /// is the document plus all the metadata attached to it.
    /// 
    /// fbmuck explanation: index is dbref, and value is all bespoke fields
    /// as well as all user properties and propdirs.
    /// 
    /// The blob contains a list containing the actual data associated with
    /// the index as well as other attributes (such as acls).  It's like a
    /// filesystem file with arbitrary metadata, like BeFS was.
    /// 
    /// Conceptually, everything is a container with labelled subcontainers.
    /// An office is a container, a file is a container, a key... well, okay,
    /// a cryptkey is a datum, not a container, but a keyring is a container.
    /// 
    /// 
    /// </remarks>
    internal abstract class Container : Org.BouncyCastle.Asn1.Asn1Encodable,
        Org.BouncyCastle.Asn1.IAsn1Convertible
    {
        #region Private Members
        /// <summary>
        /// _myBlob is the entire set of index/value pairs 
        /// </summary>
        private SortedDictionary<string, Containee> _myBlob;
        /// <summary>
        /// The acl object within _myBlob.
        /// </summary>
        private TheClerk.Access.AccessControlList _myACL;
        /// <summary>
        /// The type of content in "" node of _myBlob
        /// </summary>
        private ContentType _ContentType;
        /// <summary>
        /// content in "" node of _myBlob
        /// </summary>
        private Containee _Value;
        #endregion

        #region Constructors

        public Container()
        {
        }

        #endregion

        #region Accessors
        public AccessControlList Acl
        {
            get { return _myACL; }
            set { _myACL = value; }
        }
        public ContentType ContentType
        {
            get { return _ContentType; }
            set { _ContentType = value; }
        }
        public Containee Value
        {
            get { return _Value; }
            set { _Value = value; }
        }
        #endregion

        #region 
        #endregion

        #region Org.BouncyCastle.Asn1.Asn1Encodable abstract members

        public override Asn1Object ToAsn1Object()
        {
            throw new NotImplementedException();
        }
        #endregion
    }
}
